package com.zy.oauth;

import com.zy.common.utils.ip.IpAddressLog;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.oas.annotations.EnableOpenApi;


@EnableOpenApi
@EnableDiscoveryClient
@MapperScan(basePackages = {"com.zy.oauth.**.mapper", "com.zy.config.**.mapper"})
@SpringBootApplication(scanBasePackages = {"com.zy.oauth.**", "com.zy.common.**", "com.zy.db.**", "com.zy.config.common"})
@EnableFeignClients(basePackages = {"com.zy.**.feign"})
public class TAuthApplication {

    public static void main(String[] args) {
        Environment env = SpringApplication.run(TAuthApplication.class, args).getEnvironment();
        IpAddressLog.log(env);
    }

    /**
     * 注入restTemplate
     * *@LoadBalanced 负载均衡,添加该注解后会去找注册中心查找url地址
     * *不加可以访问第三方服务 你也可以再单独注入一个
     *
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
